import { createApp, ref } from 'vue'
import ModalAlert from '@/components/ModalAlert.vue'
export function showModal(options) {
  const visible = ref(true)
  const modalInstance = createApp(ModalAlert, {
    visible,
    ...options,
    onSure: () => {
      console.log(222222)
      destroy()
    },
  })
  const container = document.createElement('div')
  modalInstance.mount(container)
  console.log('container', container)
  document.body.appendChild(container)
  const destroy = () => {
    visible.value = false
    document.body.removeChild(container)
    modalInstance.unmount()
  }
  return {
    destroy: destroy,
  }
}
